package cn.signalpha.common.config;

import cn.signalpha.modules.system.service.ILogService;
import lombok.AllArgsConstructor;
import cn.signalpha.common.event.ApiLogListener;
import cn.signalpha.common.event.ErrorLogListener;
import cn.signalpha.common.event.UsualLogListener;
import cn.signalpha.core.launch.props.Properties;
import cn.signalpha.core.launch.server.ServerInfo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * 日志工具自动配置
 */
@AllArgsConstructor
@Configuration(proxyBeanMethods = false)
public class LogConfiguration {

	private final ILogService logService;
	private final ServerInfo serverInfo;
	private final Properties properties;

	@Bean(name = "apiLogListener")
	public ApiLogListener apiLogListener() {
		return new ApiLogListener(logService, serverInfo, properties);
	}

	@Bean(name = "errorEventListener")
	public ErrorLogListener errorEventListener() {
		return new ErrorLogListener(logService, serverInfo, properties);
	}

	@Bean(name = "usualEventListener")
	public UsualLogListener usualEventListener() {
		return new UsualLogListener(logService, serverInfo, properties);
	}

}
